<!DOCTYPE html>
<html lang="en">
<head>
    <?php 
	include "includes/ketnoi.php";
	include "includes/header.php";
	?>
</head>
    <body>
        <?php
		include "includes/narbar.php";
        $result = $conn->query("SELECT * FROM users");
        ?>
        <table border="1">
            <tr>
                <td colspan="5" class="title">DANH SÁCH USERS
                </td>
            </tr>
            <tr>
        <?php
        // put your code here
        include "includes/ketnoi.php";
        //$result = $conn->query("SELECT * FROM users");
        $result = $conn->query("SELECT users.id,groups.name,locations.name as location_name ,users.email,users.fname,users.lname,users.sex,users.created_at FROM locations INNER JOIN (groups INNER JOIN users ON groups.id = users.group_id	) ON locations.id = users.location_id ");
        //$query = mysql_query("SELECT * FROM users");
        
        echo '<div id="conten">';
        echo ' <table class="table table-striped table-bordered">';
        echo '<thead>';
        echo '<tr>';
        echo '<th>ID</th>';
        echo '<th>Group id</th>';
        echo '<th>Location id</th>';
        echo '<th>Email</th>';
        echo '<th>First name</th>';
        echo '<th>Last name</th>';
        echo '<th>Sex</th>';
        echo '<th>Created at</th>';
        echo '</tr>';
        while ($row = mysqli_fetch_array($result)) {

            echo '<tr>';
            echo '<td>'.$row["id"];'</td>';
            echo '<td>'.$row["name"];'</td>';
            echo '<td>'.$row["location_name"];'</td>';
            echo '<td>'.$row["email"];'</td>';
            echo '<td>'.$row["fname"];'</td>';
            echo '<td>'.$row["lname"];'</td>';
            echo '<td>'.$row["sex"];'</td>';
            echo '<td>'.$row["created_at"];'</td>';          
            echo '</tr>';
            }
        //mysql_close($conn);
        echo '</table>';
        echo '</div>';
		include "includes/footer.php";
        ?>
     </body>
</html>
